﻿namespace Eneta.Portal.Common.Dto
{
    /// <summary>
    /// Class for companies offices. 
    /// </summary>
    public class OfficeDto : BaseDto
    {
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        /// 	<c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        /// </exception>
        public override bool Equals(object obj)
        {
            var office = obj as OfficeDto;
            if (office == null)
                return false;

            return (Id == office.Id);
        }

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public override int GetHashCode()
        {
            var title = Title ?? string.Empty;
            return ("OfficeDto:" + Id + ":" + title).GetHashCode();
        }
    }
}
